/**
 * @author gyy
 * 俱乐部控制器
 */

package com.keepmoving.web;

import com.keepmoving.po.Club;
import com.keepmoving.service.ClubService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class AdminClubController {
    @Autowired
    ClubService clubService;
    //俱乐部列表展示
    @RequestMapping("/getClub")
    public String findClubAll(Model model){
        List<Club> clublist=clubService.findAll();
        model.addAttribute("clublist",clublist);
        return "adminClubList";
    }
    //俱乐部删除
    @RequestMapping("/adminClubDelete")
    public String adminClubDelete(int[] arrays){
        clubService.delete(arrays);
        return "redirect:getClub.action";
    }
    @RequestMapping("/deleteClub")
    @ResponseBody
    public List<Club> deleteClub(int id){
        int[] arrry={id};
        clubService.delete(arrry);
        List<Club> clubList = clubService.findAll();
        return clubList;

    }
}
